1 //CODIGO EQUIPO FACTOR COMUN
24 long long dp
[1005][1005];
26 //assert(freopen("batman.in", "r", stdin) != NULL);
29 while(p
!=0 && v
!=0 && e
!=0) {
30 vector
<power
> powers(p
);
32 for(int i
=0; i
<p
;++i
) {
34 cin
>> pp
.name
>> pp
.atk
>> pp
.e
;
37 for(int i
=0; i
<v
; ++i
) {
40 cin
>> vv
.name
>> vv
.def
>> pw
;
41 for(int k
=0; k
<pw
.size(); ++k
) {
42 if(pw
[k
]==',') pw
[k
] = ' ';
45 while(ss
>>pw
) vv
.pweak
.push_back(pw
);
46 sort(vv
.pweak
.begin(),vv
.pweak
.end());
51 memset(com
,0,sizeof com
);
52 for(int i
=0;i
<p
;++i
) {
53 for(int j
=0; j
<v
; ++j
) {
54 com
[i
+1][j
+1] = powers
[i
].atk
>=vils
[j
].def
&& binary_search(vils
[j
].pweak
.begin(),vils
[j
].pweak
.end(),powers
[i
].name
);
57 //long long dp[p+1][v+1];
58 for(int j
= 1; j
<=v
; ++j
) {
61 for(int i
= 0; i
<=p
; ++i
) {
64 for(int i
=1; i
<=p
; ++i
) {
65 for(int j
=1; j
<=v
; ++j
) {
66 dp
[i
][j
] = dp
[i
-1][j
];
67 if(com
[i
][j
]) dp
[i
][j
] = min(dp
[i
][j
],dp
[i
-1][j
-1]+powers
[i
-1].e
);
70 if(dp
[p
][v
]<=e
) cout
<< "Yes" << endl
;
71 else cout
<< "No" << endl
;
72 /*for(int i=0;i<p;++i) {
73 for(int j =0; j<v; ++j) {
74 cout << com[i+1][j+1];
78 /*for(int i=1; i<=p; ++i) {
79 for(int j =1; j<=v; ++j) {
80 cout << dp[i][j] << " ";